/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sys.service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.CacheUtils;
import com.thinkgem.jeesite.modules.sys.dao.DictDao;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;

/**
 * 字典Service
 * @author ThinkGem
 * @version 2014-05-16
 */
@Service
@Transactional(readOnly = true)
public class DictService extends CrudService<DictDao, Dict> {
	@Autowired
	private DictDao dictDao;
	/**
	 * 查询字段类型列表
	 * @return
	 */
	public List<String> findTypeList(){
		return dao.findTypeList(new Dict());
	}

	@Transactional(readOnly = false)
	public void save(Dict dict) {
		if(dict.getCategory() == null) {
			dict.setCategory(0);
		}
		super.save(dict);
		CacheUtils.remove(DictUtils.CACHE_DICT_MAP);
	}

	@Transactional(readOnly = false)
	public void delete(Dict dict) {
		super.delete(dict);
		CacheUtils.remove(DictUtils.CACHE_DICT_MAP);
	}
	
	/**
	 * 查询字典类型列表（用户字典使用该方法）
	 * @param dict
	 * @return
	 */
	public List<Dict> findTypeListByCategory(Dict dict){
		return dao.findTypeListByCategory(dict);
	}

	/**
	 *
	 * @Title: searchListByType
	 * @author: yinyanan
	 * @date: 2019年02月28日 下午16:30:50
	 * @Description: 通过字典项类型查询列表
	 * @param: @param dict
	 * @return:  List<Dict>
	 * @throws:
	 */
	public List<Dict> searchListByType(Dict dict){
		return dao.searchListByType(dict);
	}

//	public List<Dict> findListByVaccineEntId(String id){
//		return dao.findListByVaccineEntId(id);
//	}
//	public List<Dict> vaccineDicList(String type){
//		return dao.vaccineDicList(type);
//	}

	public List<Dict> findLabelByValue(Dict dict){
		return dictDao.findLabelByValue(dict);
	}

	/**
	 * @Author zhangxingliang
	 * @Description 获取带有text列结果集
	 * @Date 10:28 2019/6/20
	 **/
	public List<Map<String,Object>> findTextDictByType(Dict dict){
		return dictDao.findTextDictByType(dict);
	}

}
